package com.gome.spiderkit.client;

import com.mongodb.BasicDBObject;

public class Cookie {
	
	private BasicDBObject _cookie;
	
	public Cookie(){
		
	}
	
	public Cookie(BasicDBObject cookie) {
		_cookie = cookie;
	}
	
    boolean isNull() {
    	String name = _cookie.getString("name", "");
    	String value = _cookie.getString("value", "");
    	if (name == "" || value == "")
    		return false;
    	return true;
    }

    void setDomain(String value) {
    	_cookie.append("domain",  value);
    }
    
    String domain() {
    	return _cookie.getString("domain", "");
    }

    void setHttponly(boolean value) {
    	_cookie.append("httponly", value);
    }
    
    boolean isHttponly() {
    	return _cookie.getBoolean("httponly", true);
    }

    void setName(String value) {
    	_cookie.append("name", value);
    }
    
    String name() {
    	return _cookie.getString("name", "");
    }

    void setValue(String value) {
    	_cookie.append("value", value);
    }
    
    String value() {
    	return _cookie.getString("value", "");
    }

    void setPath(String value) {
    	_cookie.append("path", value);
    }
    
    String path() {
    	return _cookie.getString("path", "");
    }

    void setSecure(boolean value) {
    	_cookie.append("secure", value);
    }
    
    boolean secure() {
    	return _cookie.getBoolean("secure", true);
    }

    void setExpiry(double value) {
    	_cookie.append("expiry", value);
    }
    
    double expiry() {
    	return _cookie.getDouble("expiry", 0);
    }

    String expires() {
    	return _cookie.getString("expriex", "");
    }

    String toJson() {
    	return _cookie.toString();
    }
    
    BasicDBObject content() {
    	return _cookie;
    }

}
